package com.sailor.event;

import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
public class ContextRefreshedEventListener {

    @EventListener(ContextRefreshedEvent.class)
    public void onApplicationEvent(ContextRefreshedEvent event){

        if(event.getApplicationContext().getParent() == null){
            //需要执行的逻辑代码，当spring容器初始化完成后就会执行该方法。
            System.out.println("______\n容器加载完毕\n______");
        }
    }

}
